<?php
$counter=0;
function gettree($parent,$root){
	if($parent->count() > 0){
		if(!$root){
		echo "<li>".$parent->getname()."</li><ul>";}
		else{echo "<ul>";}
		$root=false;
		foreach( $parent->children() AS $child ){
			gettree($child,false);
			}
		echo "</ul>";
		}
	else{
		echo "<li>".$parent."</li>";
		}
	}

if (file_exists('site.xml')) {
    $xml = simplexml_load_file('site.xml');

gettree($xml->elements,true);

} else {
    exit('Failed to open site.xml.');
}
?>
